﻿
/* 异步请求结果返回状态码 */
var ResultStatus = { OK: 100, Failed: 101, NotLogin: 102, Unauthorized: 103 };

Date.prototype.format = function (format) {
    var o =
        {
            "M+": this.getMonth() + 1, //month
            "d+": this.getDate(),    //day
            "H+": this.getHours(),   //hour
            "m+": this.getMinutes(), //minute
            "s+": this.getSeconds(), //second
            "q+": Math.floor((this.getMonth() + 3) / 3),  //quarter
            "S": this.getMilliseconds() //millisecond
        };
    if (/(y+)/.test(format))
        format = format.replace(RegExp.$1, (this.getFullYear() + "").substr(4 - RegExp.$1.length));
    for (var k in o)
        if (new RegExp("(" + k + ")").test(format))
            format = format.replace(RegExp.$1, RegExp.$1.length == 1 ? o[k] : ("00" + o[k]).substr(("" + o[k]).length));
    return format;
};
Array.prototype.where = function (predicate) {
    var arr = this;
    var retArr = [];
    for (var i = 0; i < arr.length; i++) {
        var item = arr[i];
        if (predicate(item)) {
            retArr.push(item);
        }
    }
    return retArr;
};
Array.prototype.select = function (selector) {
    var arr = this;
    var retArr = [];
    for (var i = 0; i < arr.length; i++) {
        var item = arr[i];
        retArr.push(selector(item));
    }
    return retArr;
};
Array.prototype.first = function (predicate) {
    var arr = this;
    var retArr = [];
    for (var i = 0; i < arr.length; i++) {
        var item = arr[i];
        if (predicate(item)) {
            return item;
        }
    }
    return retArr;
};
Array.prototype.getIndex = function (id) {
    var arr = this;
    for (var i = 0; i < arr.length; i++) {
        var item = arr[i].Id;
        if (id === item) {
            return i;
        }
    }
    return -1;
};

/* $hits */
(function ($) {
    var $hits = {};
    $hits.guid = function () {

        var s = [];
        var hexDigits = "0123456789abcdef";
        for (var i = 0; i < 36; i++) {
            s[i] = hexDigits.substr(Math.floor(Math.random() * 0x10), 1);
        }
        s[14] = "4";  // bits 12-15 of the time_hi_and_version field to 0010
        s[19] = hexDigits.substr((s[19] & 0x3) | 0x8, 1);  // bits 6-7 of the clock_seq_hi_and_reserved to 01
        s[8] = s[13] = s[18] = s[23] = "-";

        var uuid = s.join("");
        return uuid;
    }
    /* 返回 json 数据 */
    $hits.get = function (url, data, callback) {
        if ($.isFunction(data)) {
            callback = data;
            data = undefined;
        }

        url = parseUrl(url);
        var ret = execAjax("GET", url, data, callback);
        return ret;
    }
    $hits.post = function (url, data, callback) {
        if ($.isFunction(data)) {
            callback = data;
            data = undefined;
        }

        var ret = execAjax("POST", url, data, callback);
        return ret;
    }

    $hits.alert = function (msg, callBack) {
        layerAlert(msg, callBack);
    }
    $hits.confirm = function (msg, callBack) {
        layerConfirm(msg, callBack);
    }
    $hits.msg = function (msg) {
        layerMsg(msg);
    }

    $hits.reload = function () {
        location.reload();
        return false;
    }


    /* 将当前 url 的参数值 */
    $hits.getQueryParam = function (name) {
        if (name === null || name === undefined || name === "")
            return "";
        name = ("" + name).toLowerCase();
        var search = location.search.slice(1);
        var arr = search.split("&");
        for (var i = 0; i < arr.length; i++) {
            var ar = arr[i].split("=");
            if (ar[0].toLowerCase() == name) {
                if (unescape(ar[1]) == 'undefined') {
                    return "";
                } else {
                    return unescape(ar[1]);
                }
            }
        }
        return "";
    }
    /* 将当前 url 参数转成一个 js 对象 */
    $hits.getQueryParams = function () {
        var params = {};
        var loc = window.location;
        var se = decodeURIComponent(loc.search);

        if (!se) {
            return params;
        }

        var paramsString;
        paramsString = se.substr(1);//将?去掉
        var arr = paramsString.split("&");
        for (var i = 0; i < arr.length; i++) {
            var item = arr[i];
            var index = item.indexOf("=");
            if (index == -1)
                continue;
            var paramName = item.substr(0, index);
            if (!paramName)
                continue;
            var value = item.substr(index + 1);
            params[paramName] = value;
        }
        return params;
    }

    /* optionList: [{"Value" : "1", "Text" : "开发部"},{"Value" : "2", "Text" : "测试部"}] */
    $hits.getOptionTextByValue = function (optionList, value, valuePropName, textPropName) {
        valuePropName = valuePropName || "Value";
        textPropName = textPropName || "Text";

        var text = "";
        var len = optionList.length;
        for (var i = 0; i < len; i++) {
            if (optionList[i][valuePropName] == value) {
                text = optionList[i][textPropName];
                break;
            }
        }

        return text;
    }

    /* 依赖 bootstrap ui */
    $hits.selectRow = function (selectedTr) {
        var c = "warning";
        $(selectedTr).addClass(c);
        $(selectedTr).siblings().removeClass(c);
        return true;
    }
    $hits.formatBool = function (val) {
        if (val == true) {
            return "是";
        }
        else if (val == false) {
            return "否";
        }

        return val;
    }

    $hits.download = function (url, method) {
        if (url) {
            //data = typeof data == 'string' ? data : jQuery.param(data);
            //var inputs = '';
            //$.each(data.split('&'), function () {
            //    var pair = this.split('=');
            //    inputs += '<input type="hidden" name="' + pair[0] + '" value="' + pair[1] + '" />';' + inputs + '
            //});
            $('<form action="' + url + '" method="' + (method || 'post') + '"></form>').appendTo('body').submit().remove();
        };
    };


    $hits.upload = function (url, data) {
        if (url && data) {
            data = typeof data == 'string' ? data : jQuery.param(data);
            var inputs = '';
            $.each(data.split('&'), function () {
                var pair = this.split('=');
                inputs += '<input type="file" name="' + pair[0] + '" value="' + pair[1] + '" />';
            });
            $('<form enctype="multipart/form-data"    action="' + url + '" method="' + ('post') + '">' + inputs + '</form>').appendTo('body').submit().remove();
        };
    };
    function execAjax(type, url, data, callback) {
        var layerIndex = layer.load(1);
        var ret = $.ajax({
            url: url,
            type: type,
            dataType: "json",
            data: data,
            complete: function (xhr) {
                layer.close(layerIndex);
            },
            success: function (result) {
                var isStandardResult = ("Status" in result) && ("Msg" in result);
                if (isStandardResult) {
                    if (result.Status == ResultStatus.Failed) {
                        layerAlert(result.Msg || "操作失败");
                        return;
                    }
                    if (result.Status == ResultStatus.NotLogin) {
                        layerAlert(result.Msg || "未登录或登录过期，请重新登录");
                        return;
                    }
                    if (result.Status == ResultStatus.Unauthorized) {
                        layerAlert(result.Msg || "权限不足，禁止访问");
                        return;
                    }

                    if (result.Status == ResultStatus.OK) {
                        /* 传 result，用 result.Data 还是 result.Msg，由调用者决定 */
                        callback(result);
                    }
                }
                else
                    callback(result);
            },
            error: errorCallback
        });
        return ret;
    }
    function errorCallback(xhr, textStatus, errorThrown) {
        var json = { textStatus: textStatus, errorThrown: errorThrown };
        alert("请求失败: " + JSON.stringify(json));
    }
    function parseUrl(url) {
        if (url.indexOf("_dc=") < 0) {
            if (url.indexOf("?") >= 0) {
                url = url + "&_dc=" + (new Date().getTime());
            } else {
                url = url + "?_dc=" + (new Date().getTime());
            }
        }
        return url;
    };

    function layerAlert(msg, callBack) {
        msg = msg == null ? "" : msg;/* layer.alert 传 null 会报错 */
        var type = 'warning';
        var icon = "";
        if (type == 'success') {
            icon = "fa-check-circle";
        }
        if (type == 'error') {
            icon = "fa-times-circle";
        }
        if (type == 'warning') {
            icon = "fa-exclamation-circle";
        }

        var idx;
        idx = layer.alert(msg, {
            icon: icon,
            title: "系统提示",
            btn: ['确认'],
            btnclass: ['btn btn-primary'],
        }, function () {
            layer.close(idx);
            if (callBack)
                callBack();
        });
    }
    function layerConfirm(content, callBack) {
        var idx;
        idx = layer.confirm(content, {
            icon: "fa-exclamation-circle",
            title: "系统提示",
            btn: ['确认', '取消'],
            btnclass: ['btn btn-primary', 'btn btn-danger'],
        }, function () {
            layer.close(idx);
            callBack();
        }, function () {

        });
    }
    function layerMsg(msg, callBack) {
        msg = msg == null ? "" : msg;/* layer.msg 传 null 会报错 */
        layer.msg(msg, { time: 2000, shift: 0 });
    }


    window.$hits = $hits;
})($);


/* $ 扩展 */
(function ($) {

    /* 设置 input 标签的值，同时触发 change 事件 */
    $.fn.setValue = function (val) {
        this.val(val);
        this.change();
    }

    /* 根据值设置 select 标签的选中项，同时触发 change 事件 */
    $.fn.setSelectedValue = function (val) {
        for (var j = 0; j < this.length; j++) {
            var selectElement = this[j];
            for (var i = 0; i < selectElement.options.length; i++) {
                var op = selectElement.options[i];
                if (op.value == val) {
                    op.selected = true;
                    $(selectElement).change();
                    break;
                }
            }
        }
    };
    $.fn.getSelectedValue = function () {
        var ret = "";
        var c = "";
        for (var j = 0; j < this.length; j++) {
            var selectElement = this[j];
            var idx = selectElement.selectedIndex;
            ret += c + selectElement[idx].value;
            c = ";";
        }

        return ret;
    };
    $.fn.getSelectedText = function () {
        var ret = "";
        var c = "";
        for (var j = 0; j < this.length; j++) {
            var selectElement = this[j];
            var idx = selectElement.selectedIndex;
            ret += c + selectElement[idx].text;
            c = ";";
        }

        return ret;
    };

    $.fn.checked = function (value) {
        if (value == true)
            value = "true";
        else if (value == false)
            value = "false";

        for (var j = 0; j < this.length; j++) {
            var ele = this[j];
            if (value === undefined || value === null)
                ele.checked = true;
            else {
                if (ele.value == value)
                    ele.checked = true;
            }
        }
    }
    $.fn.checkedValue = function () {
        for (var j = 0; j < this.length; j++) {
            var ele = this[j];
            if (ele.checked == true) {
                return ele.value;
            }
        }

        return null;
    }

    $.fn.formValid = function () {
        return $(this).valid({
            errorPlacement: function (error, element) {
                element.parents('.formValue').addClass('has-error');
                element.parents('.has-error').find('i.error').remove();
                element.parents('.has-error').append('<i class="form-control-feedback fa fa-exclamation-circle error" data-placement="left" data-toggle="tooltip" title="' + error + '"></i>');
                $("[data-toggle='tooltip']").tooltip();
                if (element.parents('.input-group').hasClass('input-group')) {
                    element.parents('.has-error').find('i.error').css('right', '33px')
                }
            },
            success: function (element) {
                element.parents('.has-error').find('i.error').remove();
                element.parent().removeClass('has-error');
            }
        });
    }

    $.fn.getFormData = function () {
        var element = $(this);
        var model = {};
        element.find('input,select,textarea').each(function (r) {
            var $this = $(this);
            var name = $this.attr('name');

            if (!name)
                return;

            var type = $this.attr('type');

            switch (type) {
                case "checkbox":
                    model[name] = $this.is(":checked");
                    break;
                case "radio":
                    if (model[name] === undefined)
                        model[name] = null;
                    if (this.checked == true)
                        model[name] = this.value;
                    break;
                case "button":
                    break;
                default:
                    var value = $this.val();
                    model[name] = value;
                    break;
            }
        });
        if ($('[name=__RequestVerificationToken]').length > 0) {
            model["__RequestVerificationToken"] = $('[name=__RequestVerificationToken]').val();
        }
        return model;
    };
    $.fn.setFormData = function (data) {
        var element = $(this);
        element.find('input,select,textarea').each(function (r) {
            var $ele = $(this);
            var name = $ele.attr('name');

            if (!name)
                return;

            var type = $ele.attr('type');

            var value = null;
            if (name in data)
                value = data[name];

            switch (type) {
                case "checkbox":
                    /* 先不管，回头在搞 */
                    //model[name] = $this.is(":checked");
                    break;
                case "radio":
                    if (value == true)
                        value = "true";
                    else if (value == false)
                        value = "false";
                    this.checked = this.value == value;
                    break;
                case "select":
                    $ele.val(value).trigger("change");
                    break;
                case "button":
                    break;
                default:
                    $ele.val(value);
                    break;
            }
        });
    };

    $.fn.bindSelect = function (options) {
        var defaults = {
            value: "Id",
            text: "Name",
            change: null,
            items: [],
            placeholder: "--请选择--"
        };
        var options = $.extend(defaults, options);
        var $element = $(this);

        if (options.placeholder !== null && options.placeholder !== undefined)
            $element.append($("<option></option>").val("").html(options.placeholder));

        items = options.items;
        $.each(items, function (i) {
            $element.append($("<option></option>").val(items[i][options.value]).html(items[i][options.text]));
        });

        if (options.change)
            $element.change(options.change);

        return;
    }

    $.fn.disable = function () {
        var $element = $(this);
        $element.attr("disabled", "disabled");
    }
    $.fn.enable = function () {
        var $element = $(this);
        $element.removeAttr("disabled");
    }
})($);


function EnsureNotNull(obj, name) {
    if (!obj)
        throw new Error("属性 " + name + " 未初始化");
};
function App(me, id) {
    return new Vue({
        el: id,
        data: {
            SearchModel: {
                keyword: ""
            },//搜索
            DeleteUrl: null,//删除
            PrintUrl: null,//打印
            ExportUrl: null,//导出
            ImportUrl: null,//导入
            MultiActionUrl: null,
            MultiActionName: null,
            ModelKeyName: "Id", /* 实体主键名称 */
            SelectAll: false,//全选
            SelectedIDs: [],//当前页勾选的id列表
            /* 如有必要，子类需重写 DataTable、Dialog */
            //DataTable: null,//new PagedDataTableViewModel(this),
            //Dialog: null,// new DialogBase(),

        },
        methods: {

            /* 搜索按钮点击事件 */
            Search: function () {
                me.LoadModels();
            },
            Add: function () {
                EnsureNotNull(me.Dialog, "Dialog");
                me.Dialog.Open(null, "添加");
            },
            Delete: function () {
                $hits.confirm("确定要删除该条数据吗？", this.OnDelete);
            },
            Edit: function () {
                EnsureNotNull(me.DataTable, "DataTable");
                EnsureNotNull(me.Dialog, "Dialog");
                me.Dialog.Open(me.DataTable.SelectedModel, "修改");
            },
            Import: function () {
                EnsureNotNull(me.ImportDialog, "Dialog");
                me.ImportDialog.Open(null, "导入");
            },
            ShowDialog: function (id) {
                if (me.ShowDialog)
                    me.ShowDialog(id);
            },
            DownLoad: function () {
                if (this.ExportUrl == null)
                    throw new Error("未指定 ExportUrl");
                var url = this.ExportUrl;
                $hits.download(url, 'get');
            },
            Disabled: function () {
                return me.DataTable == null || me.DataTable.SelectedModel == null;
            },
            OnDelete: function () {
                if (this.DeleteUrl == null)
                    throw new Error("未指定 DeleteUrl");

                var url = this.DeleteUrl;
                var params = { id: me.DataTable.SelectedModel[this.ModelKeyName] };
                $hits.post(url, params, function (result) {
                    var msg = result.Msg || "删除成功";
                    $hits.msg(msg);
                    me.DataTable.RemoveSelectedModel();
                });
            }
        },

    });
}



function PagedDataTable(me, id, mixinsobj) {
    var vm = {
        el: id,
        data: {
            Models: [],
            SelectedModel: null,
            ShipObjs: [],
            ShowFirstPage: false,
            ShowLastPage: false,
            TotalCount: 0,
            TotalPage: 0,
            CurrentPage: 0,
            SkipPage: 0,
            PageSize: 0,
            ShowPages: null,

        },
        methods: {
            SelectRow: function (model) {
                this.SelectedModel = model;
            },
            RemoveSelectedModel: function () {
                if (this.SelectedModel) {
                    var index = this.Models.getIndex(this.SelectedModel.Id);
                    this.Models.splice(index, 1); //这个方法太坑了，不能使用remove
                }
            },
            SetModels: function (models) {
                this.RowIndex = 0;
                this.Models = models;
            },
            ToFixed: function (value, decimal) {
                return value.toFixed(decimal);
            },
            //时间格式化
            DateString: function (value) {
                if (value == undefined) {
                    return "";
                }
                return value.replace('T', ' ');
            },
            DateDay: function (value) {
                if (value == undefined) {
                    return "";
                }
                return value.substr(0, 10);
            },
            Gender: function (value) {
                if (value == undefined) {
                    return "男";
                }
                return value == 1 ? '男' : '女';
            },

            GetState: function (value) {
                if (value == undefined) {
                    return "已停止";
                }
                return value ? '正在运行' : '已停止';
            },

            GetYesOrNo: function (value) {
                if (value == undefined) {
                    return "否";
                }
                return value ? '是' : '否';
            },
            GetFetchStatus: function (value) {
                if (value == undefined) {
                    return "已归还";
                }
                return value ? '已借用' : '已归还';
            },
            GetEnable: function (value) {
                if (value == undefined) {
                    return "禁用";
                }
                return value ? '启用' : '禁用';
            },
            OnClickItem: function (name, model) {
                this.SelectedModel = model;
                if (me.ClickItem)
                    me.ClickItem(name, model);
            },
            GetOrdinal: function ($index) {
                return (this.CurrentPage - 1) * this.PageSize + $index + 1;
            },
            GetOptionTextByValue: function (index, value, valuePropName, textPropName) {
                if (this.ShipObjs == null || this.ShipObjs.length <= 0) return "";
                valuePropName = valuePropName || "Value";
                textPropName = textPropName || "Text";

                var text = "";
                var len = this.ShipObjs[index].length;
                for (var i = 0; i < len; i++) {
                    if (this.ShipObjs[index][i][valuePropName] == value) {
                        text = this.ShipObjs[index][i][textPropName];
                        break;
                    }
                }

                return text;
            },
            SetPagedData: function (pagedData) {
                this.RowIndex = 0;
                this.Models = pagedData.DataList;

                this.TotalCount = pagedData.TotalCount;
                this.TotalPage = pagedData.TotalPage;
                this.CurrentPage = pagedData.CurrentPage;
                this.SkipPage = pagedData.CurrentPage;
                this.PageSize = pagedData.PageSize;

                var showPageCount = 6;

                var min = this.CurrentPage - (showPageCount / 2);

                if (min < 1)
                    min = 1;

                var max = min + showPageCount;

                if (max > this.TotalPage) {
                    max = this.TotalPage;
                    min = max - showPageCount;
                    if (min < 1)
                        min = 1;
                }

                var showPages = [];
                for (var i = min; i <= max; i++) {
                    showPages.push(i);
                }
                this.ShowPages = showPages;

                this.ShowFirstPage = (min != 1);
                this.ShowLastPage = (max != this.TotalPage);
            },
            ToPage: function (page) {
                if (page < 1 || page > this.TotalPage || page == this.CurrentPage)
                    return;
                me.LoadModels(page);
            },
        }
        ,
        filters: {
            yyyy_mm_dd: function (value) {
                if (value && value.length > 10)
                    return value.substr(0, 10);
                else return value;
            },
            Target: function (value) {
                if (value && value == 'iframe')
                    return '框架';
                else return '展开';
            }
        }
        ,
        mounted: function () { //加载完成
            var $loadingpage = top.$("#loadingPage");
            $loadingpage.hide();
        }
    };
    if (mixinsobj != null) {
        vm.mixins = [mixinsobj];
    }
    return new Vue(vm);
}
function DataTable(me, id, mixinsobj) {
    var vm = {
        el: id,
        data: {
            Models: [],
            SelectedModel: null,
            ShipObjs: [],
        },
        methods: {
            SelectRow: function (model) {
                this.SelectedModel = model;
            },
            RemoveSelectedModel: function () {
                if (this.SelectedModel) {
                    var index = this.Models.getIndex(this.SelectedModel.Id);
                    this.Models.splice(index, 1); //这个方法太坑了，不能使用remove
                }
            },
            SetModels: function (models) {
                this.RowIndex = 0;
                this.Models = models;
            },
            //时间格式化
            DateString: function (value) {
                if (value == undefined) {
                    return "";
                }
                return value.replace('T', ' ');
            },
            Gender: function (value) {
                if (value == undefined) {
                    return "男";
                }
                return value == 1 ? '男' : '女';
            },
            GetState: function (value) {
                if (value == undefined) {
                    return "已停止";
                }
                return value ? '正在运行' : '已停止';
            },
            GetYesOrNo: function (value) {
                if (value == undefined) {
                    return "否";
                }
                return value ? '是' : '否';
            },
            GetFetchStatus: function (value) {
                if (value == undefined) {
                    return "已归还";
                }
                return value ? '已借用' : '已归还';
            },
            GetEnable: function (value) {
                if (value == undefined) {
                    return "禁用";
                }
                return value ? '启用' : '禁用';
            },
            OnClickItem: function (name, model) {
                this.SelectedModel = model;
                if (me.ClickItem)
                    me.ClickItem(name, model);
            },
            GetOptionTextByValue: function (index, value, valuePropName, textPropName) {
                if (this.ShipObjs == null || this.ShipObjs.length <= 0) return "";
                valuePropName = valuePropName || "Value";
                textPropName = textPropName || "Text";

                var text = "";
                var len = this.ShipObjs[index].length;
                for (var i = 0; i < len; i++) {
                    if (this.ShipObjs[index][i][valuePropName] == value) {
                        text = this.ShipObjs[index][i][textPropName];
                        break;
                    }
                }

                return text;
            },
            appendRetract: function (level) {
                var s = "";
                for (var i = 0; i < level * 4; i++) {
                    s += "&nbsp;";
                }
                return s;
            },
            expandChildren: function (parentEle, clickEle, hideParent) {
                $arrow = $(clickEle || parentEle);
                var $tbody = $arrow.parents('tbody');
                var $parentTr = $(parentEle).parents('tr').eq(0);
                var key = "hide_" + $parentTr.attr("id");
                if (!clickEle) {
                    window[key] = !window[key];
                    $(parentEle).toggleClass("glyphicon-triangle-bottom").toggleClass("glyphicon-triangle-right");
                }
                var parentId = $parentTr.attr("id");
                var $children = $tbody.find("tr[parent-id='" + parentId + "']");
                var hideChildren = hideParent || window[key];
                var that = this;
                $.each($children, function (index, child) {
                    hideChildren ? $(child).hide() : $(child).show();
                    that.expandChildren($(child).find(".glyphicon").eq(0), $arrow, hideChildren);
                });
            }
        },
        filters: {
            yyyy_mm_dd: function (value) {
                if (value && value.length > 10)
                    return value.substr(0, 10);
                else return value;
            },
            Target: function (val) {
                if (val == "expand") {
                    return "无页面";
                } else if (val == "iframe") {
                    return "框架页";
                } else if (val == "open") {
                    return "弹出页";
                } else if (val == "blank") {
                    return "新窗口";
                }
                return val;
            }
        },
        mounted: function () { //加载完成
            var $loadingpage = top.$("#loadingPage");
            $loadingpage.hide();
        }
    };
    if (mixinsobj != null) {
        vm.mixins = [mixinsobj];
    }
    return new Vue(vm);
}
function Dialog(me, id, mixinsobj) {
    // register modal component
    Vue.component('modal', {
        template: '#modal-template',
    });
    var vm = {
        el: id,
        data: {
            /* must */
            Title: null,
            IsShow: false,
            EditModel: null,
            Model: {},//绑定到界面的 model
            Models: [],
            /* end must */
            ShipObjs: [],
        },
        methods: {
            Close: function () {
                this.IsShow = false;
            },
            Open: function (model, title) {
                this.IsShow = true;
                this.Model = {};
                if (model) {
                    this.EditModel = model;
                }
                else {
                    this.EditModel = null;
                }

                if (title)
                    this.Title = title;
                if (this.EditModel) {
                    this.Model = this.EditModel;
                }
                else {
                    this.Model = {
                        IsEnabled: true
                    };
                }
                if (me.OnOpen)
                    me.OnOpen(id);
            },
            Save: function () {
                if (me.OnSave)
                    me.OnSave(id);
            }

        },
        filters: {
            yyyy_mm_dd: function (value) {
                if (value && value.length > 10)
                    return value.substr(0, 10);
                else return value;
            }
        }
    };
    if (mixinsobj != null) {
        vm.mixins = [mixinsobj];
    }
    return new Vue(vm);

}






